
var timer = null;
var bgAudioManager = null;

const createTimeInterval = function(seconds) {
	this.clearTimer();
	var i = seconds;
	this.timer = setInterval(()=>{
		i = i - 1;
		if (i <= 0) {
			// 倒计时结束
			this.clearTimer();
			this.pauseBgAudioMusic();
		} else {
			// 倒计时中
			console.log(i);
		}
	}, 1000);
	return this.timer;
}

const clearTimer = function() {
	if(this.timer != null) {
		clearInterval(this.timer);
		this.timer = null;
	}
}

const pauseBgAudioMusic = function() {
	if (this.bgAudioManager != null) {
		this.bgAudioManager.pause();
	}
}


export default {  
	createTimeInterval,
	clearTimer,
	pauseBgAudioMusic
}